<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge,IE=9,chrome=1"><meta name="generator" content="MATLAB R2019b"><title>Lidar Sensor</title><style type="text/css">.rtcContent { padding: 30px; } .S0 { margin: 3px 10px 5px 4px; padding: 0px; line-height: 28.8px; min-height: 0px; white-space: pre-wrap; color: rgb(213, 80, 0); font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 24px; font-weight: 400; text-align: left;  }
.S1 { margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: rgb(0, 0, 0); font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;  }
.S2 { margin: 3px 10px 5px 4px; padding: 0px; line-height: 20px; min-height: 0px; white-space: pre-wrap; color: rgb(60, 60, 60); font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 20px; font-weight: 700; text-align: left;  }
.S3 { margin: 10px 0px 20px; padding-left: 0px; font-family: Helvetica, Arial, sans-serif; font-size: 14px;  }
.S4 { margin-left: 56px; line-height: 21px; min-height: 0px; text-align: left; white-space: pre-wrap;  }
.CodeBlock { background-color: #F7F7F7; margin: 10px 0 10px 0;}
.S5 { border-left: 1px solid rgb(233, 233, 233); border-right: 1px solid rgb(233, 233, 233); border-top: 1px solid rgb(233, 233, 233); border-bottom: 1px solid rgb(233, 233, 233); border-radius: 4px 4px 0px 0px; padding: 6px 45px 4px 13px; line-height: 16.996px; min-height: 18px; white-space: nowrap; color: rgb(0, 0, 0); font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 14px;  }
.S6 { color: rgb(64, 64, 64); padding: 10px 0px 6px 17px; background: rgb(255, 255, 255) none repeat scroll 0% 0% / auto padding-box border-box; font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 14px; overflow-x: hidden; line-height: 16.996px;  }
.embeddedOutputsErrorElement {min-height: 18px; max-height: 250px; overflow: auto;}
.embeddedOutputsErrorElement.inlineElement {}
.embeddedOutputsErrorElement.rightPaneElement {}
.embeddedOutputsWarningElement{min-height: 18px; max-height: 250px; overflow: auto;}
.embeddedOutputsWarningElement.inlineElement {}
.embeddedOutputsWarningElement.rightPaneElement {}
.diagnosticMessage-wrapper {font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 12px;}
.diagnosticMessage-wrapper.diagnosticMessage-warningType {color: rgb(255,100,0);}
.diagnosticMessage-wrapper.diagnosticMessage-warningType a {color: rgb(255,100,0); text-decoration: underline;}
.diagnosticMessage-wrapper.diagnosticMessage-errorType {color: rgb(230,0,0);}
.diagnosticMessage-wrapper.diagnosticMessage-errorType a {color: rgb(230,0,0); text-decoration: underline;}
.diagnosticMessage-wrapper .diagnosticMessage-messagePart,.diagnosticMessage-wrapper .diagnosticMessage-causePart {white-space: pre-wrap;}
.diagnosticMessage-wrapper .diagnosticMessage-stackPart {white-space: pre;}
.embeddedOutputsTextElement,.embeddedOutputsVariableStringElement {white-space: pre; word-wrap: initial; min-height: 18px; max-height: 250px; overflow: auto;}
.textElement,.rtcDataTipElement .textElement {padding-top: 3px;}
.embeddedOutputsTextElement.inlineElement,.embeddedOutputsVariableStringElement.inlineElement {}
.inlineElement .textElement {}
.embeddedOutputsTextElement.rightPaneElement,.embeddedOutputsVariableStringElement.rightPaneElement {min-height: 16px;}
.rightPaneElement .textElement {padding-top: 2px; padding-left: 9px;}
.S7 { border-left: 1px solid rgb(233, 233, 233); border-right: 1px solid rgb(233, 233, 233); border-top: 1px solid rgb(233, 233, 233); border-bottom: 0px none rgb(0, 0, 0); border-radius: 4px 4px 0px 0px; padding: 6px 45px 0px 13px; line-height: 16.996px; min-height: 18px; white-space: nowrap; color: rgb(0, 0, 0); font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 14px;  }
.S8 { border-left: 1px solid rgb(233, 233, 233); border-right: 1px solid rgb(233, 233, 233); border-top: 0px none rgb(0, 0, 0); border-bottom: 0px none rgb(0, 0, 0); border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 16.996px; min-height: 18px; white-space: nowrap; color: rgb(0, 0, 0); font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 14px;  }
.S9 { border-left: 1px solid rgb(233, 233, 233); border-right: 1px solid rgb(233, 233, 233); border-top: 0px none rgb(0, 0, 0); border-bottom: 1px solid rgb(233, 233, 233); border-radius: 0px 0px 4px 4px; padding: 0px 45px 4px 13px; line-height: 16.996px; min-height: 18px; white-space: nowrap; color: rgb(0, 0, 0); font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 14px;  }
.S10 { border-left: 1px solid rgb(233, 233, 233); border-right: 1px solid rgb(233, 233, 233); border-top: 0px none rgb(0, 0, 0); border-bottom: 1px solid rgb(233, 233, 233); border-radius: 0px; padding: 0px 45px 4px 13px; line-height: 16.996px; min-height: 18px; white-space: nowrap; color: rgb(0, 0, 0); font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 14px;  }
.S11 { margin: 10px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: rgb(0, 0, 0); font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;  }</style></head><body><div class = rtcContent><h1  class = 'S0'><span>Lidar Sensor</span></h1><div  class = 'S1'><span>Copyright 2018-2019 The MathWorks, Inc.</span></div><h2  class = 'S2'><span>Overview</span></h2><div  class = 'S1'><span>The Lidar Sensor allows you to simulate 2D line-of-sight sensors for visualization and algorithm prototyping. It includes a MATLAB and Simulink interface.</span></div><div  class = 'S1'><img class = "imageNode" src = "" alt = "" style = "vertical-align: baseline"></img></div><div  class = 'S1'><span style=' font-weight: bold;'>Properties:</span></div><ul  class = 'S3'><li  class = 'S4'><span style=' font-weight: bold;'>Map: </span><span>A </span><a href = "matlab: doc robotics.OccupancyGrid"><span style=' font-family: monospace;'>robotics.OccupancyGrid</span></a><span> or </span><a href = "matlab: doc robotics.BinaryOccupancyGrid"><span style=' font-family: monospace;'>robotics.BinaryOccupancyGrid</span></a></li><li  class = 'S4'><span style=' font-weight: bold;'>Sensor offset:</span><span> A 2-by-1 array of </span><span texencoding="[x; y]" style="vertical-align:-5px"><img src="" width="35.5" height="17.5" /></span><span> offset from the vehicle</span></li><li  class = 'S4'><span style=' font-weight: bold;'>Scan angles:</span><span> An N-by-1 array of scan angles about the </span><span style="font-family: STIXGeneral, STIXGeneral-webfont, serif; font-style: italic; font-weight: 400; color: rgb(0, 0, 0);">x</span><span>-axis, in radians</span></li><li  class = 'S4'><span style=' font-weight: bold;'>Maximum range:</span><span> The sensor maximum range, in meters. Any values outside this range return </span><span style=' font-family: monospace;'>NaN</span><span>. </span></li></ul><div  class = 'S1'><span style=' font-weight: bold;'>Inputs:</span></div><ul  class = 'S3'><li  class = 'S4'><span style=' font-weight: bold;'>Pose: </span><span>A 3-by-1 array representing the robot pose </span><span texencoding="[x; y; \theta]" style="vertical-align:-5px"><img src="" width="50" height="17.5" /></span><span>, in meters and radians respectively</span></li></ul><div  class = 'S1'><span style=' font-weight: bold;'>Outputs:</span></div><ul  class = 'S3'><li  class = 'S4'><span style=' font-weight: bold;'>Ranges: </span><span>An N-by-1 array of ranges, in meters, corresponding to the </span><span style=' font-weight: bold;'>Scan angles</span><span> property.</span></li></ul><h2  class = 'S2'><span>MATLAB Usage</span></h2><div  class = 'S1'><span>Create a </span><span style=' font-family: monospace;'>LidarSensor</span><span> object.</span></div><div class="CodeBlock"><div class="inlineWrapper outputs"><div  class = 'S5'><span style="white-space: pre;"><span>lidar = LidarSensor</span></span></div><div  class = 'S6'><div class="inlineElement eoOutputWrapper embeddedOutputsVariableStringElement" uid="58F47034" data-testid="output_0" data-width="428" data-height="106" data-hashorizontaloverflow="false" style="width: 458px; max-height: 261px;"><div class="textElement"><div><span class="variableNameElement">lidar = </span></div><div>  LidarSensor with properties:

         mapName: ''
    sensorOffset: [0 0]
      scanAngles: [-0.7854 0 0.7854]
        maxRange: 5</div></div></div></div></div></div><div  class = 'S1'><span>Configure the sensor properties.</span></div><div class="CodeBlock"><div class="inlineWrapper"><div  class = 'S7'><span style="white-space: pre;"><span>load </span><span style="color: rgb(160, 32, 240);">exampleMap</span></span></div></div><div class="inlineWrapper"><div  class = 'S8'><span style="white-space: pre;"><span>lidar.mapName = </span><span style="color: rgb(160, 32, 240);">'map'</span><span>;</span></span></div></div><div class="inlineWrapper"><div  class = 'S8'><span style="white-space: pre;"><span>lidar.sensorOffset = [0,0];</span></span></div></div><div class="inlineWrapper"><div  class = 'S8'><span style="white-space: pre;"><span>lidar.scanAngles = linspace(-pi/2,pi/2,11); </span><span style="color: rgb(60, 118, 61);">% 11 scans from -pi/2 to +pi/2</span></span></div></div><div class="inlineWrapper"><div  class = 'S9'><span style="white-space: pre;"><span>lidar.maxRange = 4;</span></span></div></div></div><div  class = 'S1'><span>Simulate the lidar and plot the ranges given the map and vehicle pose.</span></div><div class="CodeBlock"><div class="inlineWrapper"><div  class = 'S7'><span style="white-space: pre;"><span>pose = [2; 3; pi/4];</span></span></div></div><div class="inlineWrapper"><div  class = 'S8'><span style="white-space: pre;"><span>ranges = lidar(pose);</span></span></div></div><div class="inlineWrapper"><div  class = 'S8'><span style="white-space: pre;"><span>plot(lidar.scanAngles,ranges,</span><span style="color: rgb(160, 32, 240);">'o-'</span><span>);</span></span></div></div><div class="inlineWrapper"><div  class = 'S8'><span style="white-space: pre;"><span>xlabel(</span><span style="color: rgb(160, 32, 240);">'Angle [rad]'</span><span>)</span></span></div></div><div class="inlineWrapper outputs"><div  class = 'S10'><span style="white-space: pre;"><span>ylabel(</span><span style="color: rgb(160, 32, 240);">'Range [m]'</span><span>)</span></span></div><div  class = 'S6'><div class="inlineElement eoOutputWrapper embeddedOutputsFigure" uid="507771A3" data-testid="output_1" style="width: 458px;"><div class="figureElement"><img class="figureImage figureContainingNode" src="" style="width: 560px;"></div></div></div></div></div><div  class = 'S1'><span>Visualize using the </span><a href = "matlab:edit mrsDocVisualizer2D"><span>Robot Visualizer</span></a><span>.</span></div><div class="CodeBlock"><div class="inlineWrapper"><div  class = 'S7'><span style="white-space: pre;"><span>viz = Visualizer2D;</span></span></div></div><div class="inlineWrapper"><div  class = 'S8'><span style="white-space: pre;"><span>viz.mapName = </span><span style="color: rgb(160, 32, 240);">'map'</span><span>;</span></span></div></div><div class="inlineWrapper"><div  class = 'S8'><span style="white-space: pre;"><span>attachLidarSensor(viz,lidar)</span></span></div></div><div class="inlineWrapper outputs"><div  class = 'S10'><span style="white-space: pre;"><span>viz(pose,ranges)</span></span></div><div  class = 'S6'><div class="inlineElement eoOutputWrapper embeddedOutputsFigure" uid="9819C7D3" data-testid="output_2" style="width: 458px;"><div class="figureElement"><img class="figureImage figureContainingNode" src="" style="width: 560px;"></div></div></div></div></div><div  class = 'S11'><span style=' font-weight: bold;'>Examples</span></div><ul  class = 'S3'><li  class = 'S4'><a href = "matlab:edit mrsExampleLidarSensor"><span>Lidar sensor MATLAB example</span></a></li></ul><h2  class = 'S2'><span>Simulink Usage</span></h2><div  class = 'S1'><span>Use the </span><span style=' font-weight: bold;'>Lidar Sensor</span><span> block from the </span><span style=' font-weight: bold;'>Environments</span><span> section of the </span><a href = "matlab:mobileRoboticsLib"><span>block library</span></a><span>. </span></div><div  class = 'S1'><img class = "imageNode" src = "" width = "691" height = "291" alt = "" style = "vertical-align: baseline"></img></div><div  class = 'S1'><img class = "imageNode" src = "" width = "700" height = "323" alt = "" style = "vertical-align: baseline"></img></div><div  class = 'S1'><span style=' font-weight: bold;'>Examples</span></div><ul  class = 'S3'><li  class = 'S4'><a href = "matlab:mrsLidarModel"><span>Model with Lidar Sensor block</span></a></li><li  class = 'S4'><a href = "matlab:mrsLidarAndObjectModel"><span>Model with Lidar Sensor and Object Detector blocks</span></a></li></ul></div>
<br>
<!-- 
##### SOURCE BEGIN #####
%% Lidar Sensor
% Copyright 2018-2019 The MathWorks, Inc.
%% Overview
% The Lidar Sensor allows you to simulate 2D line-of-sight sensors for visualization 
% and algorithm prototyping. It includes a MATLAB and Simulink interface.
% 
% 
% 
% *Properties:*
%% 
% * *Map:* A <matlab: doc robotics.OccupancyGrid |robotics.OccupancyGrid|> or 
% <matlab: doc robotics.BinaryOccupancyGrid |robotics.BinaryOccupancyGrid|>
% * *Sensor offset:* A 2-by-1 array of $[x; y]$ offset from the vehicle
% * *Scan angles:* An N-by-1 array of scan angles about the $x$-axis, in radians
% * *Maximum range:* The sensor maximum range, in meters. Any values outside 
% this range return |NaN|. 
%% 
% *Inputs:*
%% 
% * *Pose:* A 3-by-1 array representing the robot pose $[x; y; \theta]$, in 
% meters and radians respectively
%% 
% *Outputs:*
%% 
% * *Ranges:* An N-by-1 array of ranges, in meters, corresponding to the *Scan 
% angles* property.
%% MATLAB Usage
% Create a |LidarSensor| object.

lidar = LidarSensor
%% 
% Configure the sensor properties.

load exampleMap
lidar.mapName = 'map';
lidar.sensorOffset = [0,0];
lidar.scanAngles = linspace(-pi/2,pi/2,11); % 11 scans from -pi/2 to +pi/2
lidar.maxRange = 4;
%% 
% Simulate the lidar and plot the ranges given the map and vehicle pose.

pose = [2; 3; pi/4];
ranges = lidar(pose);
plot(lidar.scanAngles,ranges,'o-');
xlabel('Angle [rad]')
ylabel('Range [m]')
%% 
% Visualize using the <matlab:edit mrsDocVisualizer2D Robot Visualizer>.

viz = Visualizer2D;
viz.mapName = 'map';
attachLidarSensor(viz,lidar)
viz(pose,ranges)
%% 
% *Examples*
%% 
% * <matlab:edit mrsExampleLidarSensor Lidar sensor MATLAB example>
%% Simulink Usage
% Use the *Lidar Sensor* block from the *Environments* section of the <matlab:mobileRoboticsLib 
% block library>. 
% 
% 
% 
% 
% 
% *Examples*
%% 
% * <matlab:mrsLidarModel Model with Lidar Sensor block>
% * <matlab:mrsLidarAndObjectModel Model with Lidar Sensor and Object Detector 
% blocks>
##### SOURCE END #####
--></body></html>